export default class ImageCacheHandler {
    sqlite: any
    constructor(sqlite: any) {
        this.sqlite = sqlite
    }

    getCache(url: string) {
        return new Promise((resolve, reject) => {
            this.sqlite.img
                .getCache(url)
                .then((list: any) => {
                    resolve(list)
                })
                .catch(() => {
                    reject()
                })
        })
    }
    saveOrUpdate(url: string, local: string) {
        return new Promise((resolve, reject) => {
            this.sqlite.img.saveOrUpdate(url, local).then((res: any)=>{
                resolve(res)
            }).catch(()=>{
                reject()
            })
        })
    }
    delete() {
        return new Promise((resolve, reject) => {
            this.sqlite.img
                .delete()
                .then(() => {
                    console.log('删除完成')
                    resolve('删除完成')
                })
                .catch(() => {
                    console.log('删除异常')
                    reject('删除异常')
                })
        })
    }
}
